package api.ttfeed;

import android.content.Context;

import java.lang.ref.SoftReference;
import java.util.ArrayList;

import api.bean.API_TT_FeedBean;

public abstract class Feed_API_TT {

    public static String clazz = "com.dotools.toutiaolibrary.TT_Feed";

    private static SoftReference<Feed_API_TT> sf;

    public synchronized static Feed_API_TT getInstance() {

        if (sf == null || sf.get() == null) {
            Object o = null;
            try {
                o = Class.forName(clazz).newInstance();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
            if (o != null) {
                sf = new SoftReference<>((Feed_API_TT) o);
                return (Feed_API_TT) o;
            }
        }
        return sf == null ? null : sf.get();
    }

    public abstract void LoadTTFeed(Context context, String appid, String adposid, int count,int downloadMode,boolean isDebug, final TTFeedListener listener);

    public interface TTFeedListener {
        void onError(int code, String message);
        void onFeedLoad(ArrayList<API_TT_FeedBean> ads);
    }
}